<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Demo</title>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=811417de1d755929db362be5ac388721"></script>
<script src="src/js/wgs2mars.min.js"></script>
<style>
	#map {
		width: 100%;
		height: 300px;
	}
</style>
</head>

<body>
<button id="test">纠偏测试</button>
<div id="map"></div>
<script>
var mapObj;
function mapInit() {
    mapObj = new AMap.Map("map",{
        //二维地图显示视口
        view: new AMap.View2D({
        	center:new AMap.LngLat(119.3122312,26.0240049),
            zoom:15 //地图显示的缩放级别
        })
    });

    AMap.event.addListener(mapObj,'complete',function(){
        var lng = 119.3122312, lat = 26.0240049;
        var btn = document.getElementById('test');

        addMarker(lng,lat);
        btn.onclick = function(){
        	var trueLoc = transformFromWGSToGCJ(lng,lat);
            console.log(trueLoc);
        	addMarker(trueLoc.lng,trueLoc.lat);
        	mapObj.panTo(new AMap.LngLat(trueLoc.lng,trueLoc.lat));
        }
    });
}
//在地图上添加点标记函数
function addMarker(lng,lat){
	marker=new AMap.Marker({				  
	icon:new AMap.Icon({    //复杂图标
			size:new AMap.Size(28,37),//图标大小
			image:"http://webapi.amap.com/images/custom_a_j.png", //大图地址
			imageOffset:new AMap.Pixel(-28,0)//相对于大图的取图位置
		}),
	position:new AMap.LngLat(lng,lat)
	});
	marker.setMap(mapObj);  //在地图上添加点
}

mapInit();
</script>
</body>
</html>